/**
 * @file       LCDApp.h
 * @brief      TODO
 * @author     Huabo Zheng
 * @date       Jan 12, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */

#ifndef LCDAPP_H_
#define LCDAPP_H_

#include "EventHandler.h"
#include <string>
#include <signal.h>

namespace NS_LCD_AFW
{
class CPanel;

class CLCDApp: public CEventHandler
{
public:
	CLCDApp();
	virtual ~CLCDApp();

public:
	int setDaemonize();
	int hookSignal(int signo, void (*func)(int));

	CLCDApp *GetApp() const;
	virtual CPanel * GetMainPanel()=0;

	virtual int run();
	virtual int initApp(int argc, char *argv[]);

	int initInstance();
	int exitInstance();



protected:
	int peekEvent(IEvent *&pEvent);
protected:
	virtual int onInitInstance();
	virtual int onExitInstance();
	virtual int onIdle(long lCount);
	virtual int onBusy(long lCount);

protected:
	virtual bool pumpEvent(IEvent *&pEvent);
	virtual bool preTranslateEvent(IEvent *pEvent);
	virtual bool translateEvent(IEvent *pEvent);
	virtual bool dispatchEvent(IEvent *pEvent);
private:
	CLCDApp * m_pCurApp;
	//CPanel  * m_pMainPanel;
	std::string m_strAppName;

private:
	static void signalFunc(int signo);

private:
	DISABLE_COPY_CONSTRUCTOR_AND_ASSIGN_REFERENCE(CLCDApp);

};

} /* namespace NS_LCD_AFW */
#endif /* LCDAPP_H_ */
